'''
Created on Apr 6, 2011

@author: riche
'''

from ft.framework import application, connector
from ft.framework.file_io import file_reader, file_writer
from ft.directory import localhost
from ft.apps.gamma import bloomhj

class GammaApp(application.Application):
    
    def __init__(self):
        application.Application.__init__(self)
        frA = file_reader.FileReaderComponent('{}ft/gamma/TEST_INPUT_A.txt'.format(localhost.local_directory.package_root), 'ARead')
        frB = file_reader.FileReaderComponent('{}ft/gamma/TEST_INPUT_B.txt'.format(localhost.local_directory.package_root), 'BRead')
        fw = file_writer.FileWriterComponent('{}ft/gamma/TEST_OUTPUT.txt'.format(localhost.local_directory.package_root))
        hj = bloomhj.ParBloomHashJoinAbs('HashJoin_alg0')
        self.add_components([frA, frB, fw, hj])
        hj_fw = connector.Connector(self._components['HashJoin_alg0'].get_endpoint('AB'),
                                    fw.get_input_endpoint())
        frA_hj = connector.Connector(frA.get_output_endpoint(),
                                    self._components['HashJoin_alg0'].get_endpoint('A'))
        frB_hj = connector.Connector(frB.get_output_endpoint(),
                                    self._components['HashJoin_alg0'].get_endpoint('B'))
        self.add_connections([frA_hj, frB_hj, hj_fw])
        self.resolve_abstractions()
        self.instrument('{}ft/gamma/data/'.format(localhost.local_directory.package_root))

if __name__ == '__main__':
    app = GammaApp()
    app.execute(True, 1)